package com.zmm.myyimixian.ui.activity.setting;

import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;

import com.zmm.myyimixian.MyApp;
import com.zmm.myyimixian.R;
import com.zmm.myyimixian.base.BaseActivity;

import butterknife.BindView;
import butterknife.OnClick;
import cn.bmob.v3.BmobUser;

/**
 * 设置界面
 */
public class SettingActivity extends BaseActivity {

    @BindView(R.id.reg_toolbar)
    Toolbar loginToolbar;//toolbar
    @BindView(R.id.setting_btn_cancel)
    Button btnCancel;//退出按钮

    @Override
    protected void initView() {
        loginToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        if (MyApp.isLogin()) {//登陆以后显示退出登陆按钮
            btnCancel.setVisibility(View.VISIBLE);
        } else {//没有登陆不显示按钮
            btnCancel.setVisibility(View.GONE);
        }
    }

    @OnClick({R.id.setting_btn_cancel})
    public void onClick(View view) {
        if (view.getId()== R.id.setting_btn_cancel) {
            BmobUser.logOut(SettingActivity.this);   //清除缓存用户对象
            MyApp.cancle();//注销登陆
            finish();
        }
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_setting;
    }
}
